<template>
  <div>
    <table border="1" width="100%" style="border: 1px solid gainsboro">
          <tr >
               <th v-for="(item,index) in alsy" :key="index">{{item}}</th>
          </tr>
        <tr v-for="(item, index) in this.items" :key="index">
          <th v-for="(item, i) in item" :key="i" v-html="showDate(item)"></th>
        </tr>
      <tbody></tbody>
    </table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [
        {
          date: "ETTS0986765616272657",
          name: "ok",
          address: "ok",
        },
        {
          date: "ETTS0986765616272657",
          name: "ok",
          address: "ok",
        },
        {
          date: "ETTS0986765616272657",
          name: "ok",
          address: "ok",
        },
      ],
      items: [],
      search: "NG",
      list: [],
      alsy:['ABI','DOA','EAC','Result']
    };
  },
  sockets: {
    alysislen(data) {
      if (data.length == 0) {
        this.$alert("查询结果未能返回，请重新输入", "消息提示", {
          confirmButtonText: "确定",
          callback: (action) => {
            this.$message({
              type: "info",
              message: `action: ${action}`,
            });
          },
        });
      } else {
        let tempdata = JSON.parse(data);
        this.items = tempdata.table1;
        sessionStorage.setItem("tempdata", JSON.stringify(tempdata));
      }
    },
  },
  created() {
    let data = sessionStorage.getItem("tempdata");
    let dataquery = JSON.parse(data);
    this.items = dataquery.table1;
    console.log(this.items);
    for (let i = 0; i < this.items.length; i++) {
      let obj = {
        ABI: this.items[i][1],
        DOA: this.items[i][2],
        EAC: this.items[i][3],
        Result: this.items[i][4],
        Class: this.items[i][5],
      };
      this.list.push(obj);
    }
    console.log(this.list);
  },
  mounted() {},
  computed: {
    tables: function () {
      var val = this.search;
      if (val) {
        return this.items.filter((data) => {
          return Object.keys(data).some((key) => {
            return String(data[key].toLowerCase().indexOf(val) > -1);
          });
        });
      }
      return this.items;
    },
  },
  methods: {
    // 筛选变色
    showDate(val) {
      if (val.indexOf(this.search) !== -1 && this.search !== "") {
        return val.replace(
          this.search,
          '<font color="#FF0000">' + this.search + "</font>"
        );
      } else {
        return val;
      }
    },
  },
};
</script>

<style  scoped>
</style>





